import django
import os
import random
import string
import sys

# from django.db import connection
# from django.db.models import Count
#
#
# from utils import encrypt_util

sys.path.insert(0, "/onecity/ayc_bbs")
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ayc_bbs.settings')
django.setup()

# import uuid
from django.conf import settings
# from forum.models import Topic, Attachments
from user_app.models import AccountInfo
from utils.encrypt_util import md5


def create_account(phone):
    ran_name = ''.join(random.sample(string.ascii_letters + string.digits, 8))

    password = '666666'
    new_account = AccountInfo()
    new_account.nick_name = ran_name
    new_account.mobile_phone = phone
    new_account.password = md5(settings.PASSWORD_SALT + password)
    new_account.avatar = r'https://91mogo.oss-cn-beijing.aliyuncs.com/bbs/default1.png'
    new_account.save()


if __name__ == '__main__':
    ph = [
        "17912341111",
        "17912341112",
        "17912341113",
        "17912341114",
        "17912341115",
        "17912341116",
        "17912341117",
        "17912341118",
        "17912341119",
        "17912341121",
        "17912341122",
        "17912341123",
        "17912341124",
        "17912341125",
        "17912341126",
        "17912341127",
        "17912341128",
        "17912341129",
        "17912341131",
        "17912341132",
    ]
    for i in ph:
        create_account(i)

    pass
